package esjd.demo.controller;

import esjd.demo.serivce.SerivceIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
public class CotrollerIndex {

    @Autowired
    private SerivceIndex serivceIndex;


    @GetMapping("/save/{key}")
    public boolean save(@PathVariable("key") String key) throws IOException {
        return serivceIndex.saveList(key);
    }


    @GetMapping("/list/{key}/{page}/{size}")
    public List<Map<String, Object>> list(@PathVariable("key") String key,
                                          @PathVariable("page") Integer page,
                                          @PathVariable("size") Integer size) throws IOException {
        return serivceIndex.getlist(key,page,size);
    }

}
